﻿<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
  
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Custom Attributes | DotNetHelper.ObjectToSql </title>
    <meta name="viewport" content="width=device-width">
    <meta name="title" content="Custom Attributes | DotNetHelper.ObjectToSql ">
    <meta name="generator" content="docfx 2.56.1.0">
    
    <link rel="shortcut icon" href="../../logo/favicon.ico">
    <link rel="stylesheet" href="../../styles/docfx.vendor.css">
    <link rel="stylesheet" href="../../styles/docfx.css">
    <link rel="stylesheet" href="../../styles/main.css">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
    <meta property="docfx:navrel" content="toc.html">
    <meta property="docfx:tocrel" content="../toc.html">
    
    <meta property="docfx:rel" content="../../">
    
  </head>  <body data-spy="scroll" data-target="#affix" data-offset="120">
    <div id="wrapper">
      <header>
        
        <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
          <div class="container">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              
              <a class="navbar-brand" href="../../index.html">
                <img id="logo" class="svg" src="../../logo.svg" alt="">
              </a>
            </div>
            <div class="collapse navbar-collapse" id="navbar">
              <form class="navbar-form navbar-right" role="search" id="search">
                <div class="form-group">
                  <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
                </div>
              </form>
                
                <ul class="nav level1 navbar-nav">
                      <li>
                          <a href="../../index.html" title="Home">Home</a>
                      </li>
                      <li>
                          <a href="../index.html" title="Tutorials">Tutorials</a>
                      </li>
                      <li>
                          <a href="../../api/DotNetHelper.ObjectToSql.Attribute.html" title="API">API</a>
                      </li>
                      <li>
                          <a href="https://github.com/TheMofaDe/DotNetHelper.ObjectToSql/blob/master/CHANGELOG.md" title="Change Log">Change Log</a>
                      </li>
                      <li>
                          <a href="https://github.com/TheMofaDe/DotNetHelper.ObjectToSql" title="Github">Github</a>
                      </li>
                </ul>    </div>
          </div>
        </nav>
        
        <div class="subnav navbar navbar-default">
          <div class="container hide-when-search" id="breadcrumb">
            <ul class="breadcrumb">
              <li></li>
            </ul>
          </div>
        </div>
      </header>
      <div class="container body-content">
        
        <div id="search-results">
          <div class="search-list"></div>
          <div class="sr-items">
            <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
          </div>
          <ul id="pagination"></ul>
        </div>
      </div>
      <div role="main" class="container body-content hide-when-search">
        <div class="sidenav hide-when-search">
          <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
          <div class="sidetoggle collapse" id="sidetoggle">
            <div>
              <div class="sidefilter">
                <form class="toc-filter">
                  <span class="glyphicon glyphicon-filter filter-icon"></span>
                  <input type="text" id="toc_filter_input" placeholder="Enter here to filter..." onkeypress="if(event.keyCode==13) {return false;}">
                </form>
              </div>
              <div class="sidetoc">
                <div class="toc" id="toc">
                  
                  <ul class="nav level1">
                    <li class="">
                      <a href="../index.html" title="Home" class="">Home</a>
                    </li>
                    <li class="active">
                      <a href="../Attributes/attribute.html" title="Attributes" class="active">Attributes</a>
                    </li>
                    <li class="">
                      <span class="expand-stub"></span>
                      <a class="">Generating SQL</a>
                        
                        <ul class="nav level2">
                          <li class="">
                            <a href="../GenerateSql/object2sql.html" title="Object To Sql" class="">Object To Sql</a>
                          </li>
                          <li class="">
                            <a href="../GenerateSql/datatable2sql.html" title="DataTable To Sql" class="">DataTable To Sql</a>
                          </li>
                          <li class="">
                            <a href="../GenerateSql/readablesql.html" title="Readable Sql" class="">Readable Sql</a>
                          </li>
                        </ul>  </li>
                  </ul>        </div>
              </div>
            </div>
          </div>
        </div>
        <div class="article row grid-right">
          <div class="col-md-10">
            <article class="content wrap" id="_content" data-uid="">
<h1 id="custom-attributes">Custom Attributes</h1>

<p>In the secnarios where you need to build Update,Delete, or Upsert Statements. Attributes are use to generate the where clause. This library has its own custom attributes and can also work with the common DataAnnotation attributes. With the support of DataAnnotation this means this library could be paired with your favorite orm like Dapper or Enitity Framework</p>
<h5 id="mark-a-property-as-an-identity-fields">Mark a property as an identity fields.</h5>
<pre><code class="lang-csharp">[SqlColumn(SetIsIdentityKey = true)]
OR 
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] // using data annotation
</code></pre>
<h5 id="mark-a-property-as-a-key-field">Mark a property as a key field.</h5>
<pre><code class="lang-csharp">[SqlColumn(SetIsIdentityKey = true)]
OR 
[Key] // using data annotation
</code></pre>
<h5 id="mark-a-property-as-a-json-xml-or-csv-field">Mark a property as a Json, Xml, Or Csv Field.</h5>
<pre><code class="lang-csharp">[SqlColumn(SerializableType = SerializableType.Json)]
</code></pre>
<h5 id="mark-a-property-to-be-ignored-">Mark a property to be ignored .</h5>
<pre><code class="lang-csharp">[SqlColumn(Ignore = true)]
OR 
[NotMapped] // using data annotation
</code></pre>
<!-- 
#### Storing Columns As CSV, XML, & JSON

```csharp
[SqlColumn(SerializableType = SerializableType.Json)]
or 
[SqlColumn(SerializableType = SerializableType.Xml)]
or 
[SqlColumn(SerializableType = SerializableType.Csv)]
```  -->
</article>
          </div>
          
          <div class="hidden-sm col-md-2" role="complementary">
            <div class="sideaffix">
              <div class="contribution">
                <ul class="nav">
                  <li>
                    <a href="https://github.com/TheMofaDe/DotNetHelper.ObjectToSql/blob/master/docs/tutorials/Attributes/attribute.md/#L1" class="contribution-link">Improve this Doc</a>
                  </li>
                </ul>
              </div>
              <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
              <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
              </nav>
            </div>
          </div>
        </div>
      </div>
      
      <footer>
        <div class="grad-bottom"></div>
        <div class="footer">
          <div class="container">
            <span class="pull-right">
              <a href="#top">Back to top</a>
            </span>
            Copyright © 2019  <strong>Joseph McNeal Jr</strong>
            
          </div>
        </div>
      </footer>
    </div>
    
    <script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
    <script type="text/javascript" src="../../styles/docfx.js"></script>
    <script type="text/javascript" src="../../styles/main.js"></script>
  </body>
</html>
